﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ClusterMethod.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The cluster method.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The cluster method.
    /// </summary>
    public class ClusterMethod : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterMethod"/> class.
        /// </summary>
        public ClusterMethod()
        {
            this.Files = new HashSet<File>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the archive location.
        /// </summary>
        public virtual string ArchiveLocation { get; set; }

        /// <summary>
        /// Gets or sets the comments.
        /// </summary>
        public virtual string Comments { get; set; }

        /// <summary>
        /// Gets or sets the files.
        /// </summary>
        public virtual ICollection<File> Files { get; set; }

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        public virtual ClusterMethodType Type { get; set; }

        #endregion
    }

    /// <summary>
    /// The cluster method mapping.
    /// </summary>
    public class ClusterMethodMapping : ClassMapping<ClusterMethod>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterMethodMapping"/> class.
        /// </summary>
        public ClusterMethodMapping()
        {
            this.ManyToOne(x => x.Type);
            this.Property(x => x.ArchiveLocation);
            this.Property(x => x.Comments, m => m.Length(int.MaxValue / 2));
            this.Set(x => x.Files, c => { }, m => m.ManyToMany());
        }

        #endregion
    }
}